#pragma once
#include "StdAfx.h"


/*
	This is the class that ensures the compatibility between standard ASCII and Unicode
*/
//the short version for a TCHAR string
typedef std::basic_string<TCHAR, std::char_traits<TCHAR>, std::allocator<TCHAR>> tstring;

class BBString : public tstring
{
public:
	//various constructors
	BBString(void);
	BBString(const wchar_t*);
	BBString(const BBString&);
	BBString(const std::string&);
	BBString(const char*);
	~BBString(void);
	//various casting operators
	operator const wchar_t*();
	operator const char*();
	operator std::string();

	//assignment operators
	BBString& operator =(const BBString&);
	//case insensitive comparison
	bool operator ^(BBString&);
	//substring comparison
	bool operator %(BBString&);
	//addition operators
	BBString operator +(BBString&);
	BBString& operator +=(BBString&);
	bool operator ==(BBString&);
	bool operator !=(BBString&);
	//case conversions
	BBString toLower();
	BBString toUpper();
	//int to text and text to int conversions
	static BBString intToAlpha(int);
	static int alphaToInt(BBString&);
	//WARNING
	//TRANSFORMS ALPHA TO FLOAT, NOT TO REAL
	//FIX WHEN POSSIBLE
	static real alphaToReal(BBString&);

private:
	//helper functions
	//BBString& operator +(BBString&);
	void convert(const char*);
	void convert(const wchar_t*);
	//check to know if the string is using wchar_t or char
	bool isWide();
	//the string used for casting this string to const char*
	std::string mbCopy;
};
//insertion operators used to simplify string creation
BBString operator <<(BBString, const char*);
BBString& operator <<=(BBString&, const char*);
